.class public Lcom/inmobi/commons/internal/JSONPayloadCreator;
.super Ljava/lang/Object;
.source "JSONPayloadCreator.java"

# interfaces
.implements Lcom/inmobi/commons/internal/PayloadCreator;


# direct methods
.method public constructor <init>()V
    .locals 0

    .prologue
    .line 18
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method private a(Lcom/inmobi/commons/thinICE/icedatacollector/Sample;Lcom/inmobi/commons/internal/ThinICEConfig;)Lorg/json/JSONObject;
    .locals 5
    .parameter
    .parameter

    .prologue
    const/4 v2, 0x0

    .line 57
    :try_start_0
    new-instance v1, Lorg/json/JSONObject;

    invoke-direct {v1}, Lorg/json/JSONObject;-><init>()V

    .line 58
    iget-boolean v0, p2, Lcom/inmobi/commons/internal/ThinICEConfig;->k:Z

    if-eqz v0, :cond_0

    .line 59
    const-string v0, "c-ap"

    iget-object v3, p1, Lcom/inmobi/commons/thinICE/icedatacollector/Sample;->connectedWifiAp:Lcom/inmobi/commons/thinICE/wifi/WifiInfo;

    invoke-direct {p0, v3}, Lcom/inmobi/commons/internal/JSONPayloadCreator;->a(Lcom/inmobi/commons/thinICE/wifi/WifiInfo;)Lorg/json/JSONObject;

    move-result-object v3

    invoke-virtual {v1, v0, v3}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;

    .line 60
    :cond_0
    iget-boolean v0, p2, Lcom/inmobi/commons/internal/ThinICEConfig;->j:Z

    if-eqz v0, :cond_1

    .line 61
    const-string v0, "c-sid"

    iget-object v3, p1, Lcom/inmobi/commons/thinICE/icedatacollector/Sample;->servingCellId:Ljava/lang/String;

    invoke-virtual {v1, v0, v3}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;

    .line 63
    :cond_1
    iget-boolean v0, p2, Lcom/inmobi/commons/internal/ThinICEConfig;->l:Z

    if-eqz v0, :cond_3

    .line 64
    new-instance v3, Lorg/json/JSONArray;

    invoke-direct {v3}, Lorg/json/JSONArray;-><init>()V

    .line 65
    iget-object v0, p1, Lcom/inmobi/commons/thinICE/icedatacollector/Sample;->visibleWifiAp:Ljava/util/List;

    if-nez v0, :cond_4

    .line 74
    :cond_2
    invoke-virtual {v3}, Lorg/json/JSONArray;->length()I

    move-result v0

    if-lez v0, :cond_3

    .line 75
    const-string v0, "v-ap"

    invoke-virtual {v1, v0, v3}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;

    .line 77
    :cond_3
    invoke-virtual {v1}, Lorg/json/JSONObject;->length()I

    move-result v0

    const/4 v3, 0x1

    if-le v0, v3, :cond_6

    .line 78
    const-string v0, "ts"

    iget-wide v3, p1, Lcom/inmobi/commons/thinICE/icedatacollector/Sample;->utc:J

    invoke-virtual {v1, v0, v3, v4}, Lorg/json/JSONObject;->put(Ljava/lang/String;J)Lorg/json/JSONObject;

    move-object v0, v1

    .line 83
    :goto_0
    return-object v0

    .line 68
    :cond_4
    iget-object v0, p1, Lcom/inmobi/commons/thinICE/icedatacollector/Sample;->visibleWifiAp:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v4

    :cond_5
    :goto_1
    invoke-interface {v4}, Ljava/util/Iterator;->hasNext()Z

    move-result v0

    if-eqz v0, :cond_2

    invoke-interface {v4}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/inmobi/commons/thinICE/wifi/WifiInfo;

    .line 69
    invoke-direct {p0, v0}, Lcom/inmobi/commons/internal/JSONPayloadCreator;->a(Lcom/inmobi/commons/thinICE/wifi/WifiInfo;)Lorg/json/JSONObject;

    move-result-object v0

    .line 70
    if-eqz v0, :cond_5

    .line 71
    invoke-virtual {v3, v0}, Lorg/json/JSONArray;->put(Ljava/lang/Object;)Lorg/json/JSONArray;
    :try_end_0
    .catch Lorg/json/JSONException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_1

    .line 82
    :catch_0
    move-exception v0

    move-object v0, v2

    .line 83
    goto :goto_0

    :cond_6
    move-object v0, v2

    .line 81
    goto :goto_0
.end method

.method private a(Lcom/inmobi/commons/thinICE/wifi/WifiInfo;)Lorg/json/JSONObject;
    .locals 7
    .parameter

    .prologue
    .line 88
    new-instance v0, Lorg/json/JSONObject;

    invoke-direct {v0}, Lorg/json/JSONObject;-><init>()V

    .line 90
    :try_start_0
    const-string v1, "bssid"

    const-string v2, "0x%012x"

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/Object;

    const/4 v4, 0x0

    iget-wide v5, p1, Lcom/inmobi/commons/thinICE/wifi/WifiInfo;->bssid:J

    invoke-static {v5, v6}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v5

    aput-object v5, v3, v4

    invoke-static {v2, v3}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v0, v1, v2}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;

    .line 91
    const-string v1, "essid"

    iget-object v2, p1, Lcom/inmobi/commons/thinICE/wifi/WifiInfo;->ssid:Ljava/lang/String;

    invoke-virtual {v0, v1, v2}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;

    .line 92
    const-string v1, "rssi"

    iget v2, p1, Lcom/inmobi/commons/thinICE/wifi/WifiInfo;->rssi:I

    invoke-virtual {v0, v1, v2}, Lorg/json/JSONObject;->put(Ljava/lang/String;I)Lorg/json/JSONObject;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 97
    :goto_0
    return-object v0

    .line 93
    :catch_0
    move-exception v0

    .line 94
    const/4 v0, 0x0

    goto :goto_0
.end method


# virtual methods
.method public toPayloadString(Ljava/util/List;Landroid/content/Context;)Ljava/lang/String;
    .locals 8
    .parameter
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/List",
            "<",
            "Lcom/inmobi/commons/thinICE/icedatacollector/Sample;",
            ">;",
            "Landroid/content/Context;",
            ")",
            "Ljava/lang/String;"
        }
    .end annotation

    .prologue
    const/4 v1, 0x0

    const/4 v7, -0x1

    .line 21
    new-instance v2, Lorg/json/JSONObject;

    invoke-direct {v2}, Lorg/json/JSONObject;-><init>()V

    .line 22
    new-instance v3, Lorg/json/JSONArray;

    invoke-direct {v3}, Lorg/json/JSONArray;-><init>()V

    .line 23
    sget-object v0, Lcom/inmobi/commons/internal/InternalSDKUtil;->a:Lcom/inmobi/commons/internal/CommonsConfig;

    invoke-virtual {v0}, Lcom/inmobi/commons/internal/CommonsConfig;->getTic()Lcom/inmobi/commons/internal/ThinICEConfig;

    move-result-object v4

    .line 24
    invoke-interface {p1}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v5

    :goto_0
    invoke-interface {v5}, Ljava/util/Iterator;->hasNext()Z

    move-result v0

    if-eqz v0, :cond_0

    invoke-interface {v5}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/inmobi/commons/thinICE/icedatacollector/Sample;

    .line 25
    invoke-direct {p0, v0, v4}, Lcom/inmobi/commons/internal/JSONPayloadCreator;->a(Lcom/inmobi/commons/thinICE/icedatacollector/Sample;Lcom/inmobi/commons/internal/ThinICEConfig;)Lorg/json/JSONObject;

    move-result-object v0

    invoke-virtual {v3, v0}, Lorg/json/JSONArray;->put(Ljava/lang/Object;)Lorg/json/JSONArray;

    goto :goto_0

    .line 29
    :cond_0
    :try_start_0
    invoke-virtual {v3}, Lorg/json/JSONArray;->length()I

    move-result v0

    if-lez v0, :cond_1

    .line 30
    const-string v0, "payload"

    invoke-virtual {v2, v0, v3}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;

    .line 32
    :cond_1
    invoke-static {p2}, Lcom/inmobi/commons/thinICE/cellular/CellUtil;->getCellNetworkInfo(Landroid/content/Context;)Lcom/inmobi/commons/thinICE/cellular/CellOperatorInfo;

    move-result-object v0

    .line 34
    iget v3, v4, Lcom/inmobi/commons/internal/ThinICEConfig;->g:I

    const/4 v5, 0x1

    invoke-static {v3, v5}, Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;->bitTest(II)Z

    move-result v3

    if-nez v3, :cond_3

    iget v3, v0, Lcom/inmobi/commons/thinICE/cellular/CellOperatorInfo;->simMcc:I

    if-ne v3, v7, :cond_2

    iget v3, v0, Lcom/inmobi/commons/thinICE/cellular/CellOperatorInfo;->simMnc:I

    if-eq v3, v7, :cond_3

    .line 36
    :cond_2
    const-string v3, "s-ho"

    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    iget v6, v0, Lcom/inmobi/commons/thinICE/cellular/CellOperatorInfo;->simMcc:I

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, "_"

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    iget v6, v0, Lcom/inmobi/commons/thinICE/cellular/CellOperatorInfo;->simMnc:I

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v2, v3, v5}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;

    .line 37
    :cond_3
    iget v3, v4, Lcom/inmobi/commons/internal/ThinICEConfig;->g:I

    const/4 v4, 0x2

    invoke-static {v3, v4}, Lcom/inmobi/commons/thinICE/icedatacollector/ThinICEConfigSettings;->bitTest(II)Z

    move-result v3

    if-nez v3, :cond_5

    iget v3, v0, Lcom/inmobi/commons/thinICE/cellular/CellOperatorInfo;->currentMcc:I

    if-ne v3, v7, :cond_4

    iget v3, v0, Lcom/inmobi/commons/thinICE/cellular/CellOperatorInfo;->currentMnc:I

    if-eq v3, v7, :cond_5

    .line 39
    :cond_4
    const-string v3, "s-co"

    new-instance v4, Ljava/lang/StringBuilder;

    invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V

    iget v5, v0, Lcom/inmobi/commons/thinICE/cellular/CellOperatorInfo;->currentMcc:I

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v4

    const-string v5, "_"

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    iget v0, v0, Lcom/inmobi/commons/thinICE/cellular/CellOperatorInfo;->currentMnc:I

    invoke-virtual {v4, v0}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-virtual {v2, v3, v0}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;

    .line 41
    :cond_5
    invoke-static {}, Ljava/util/Calendar;->getInstance()Ljava/util/Calendar;

    move-result-object v0

    .line 42
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    .line 43
    const-string v3, "tz"

    const/16 v4, 0xf

    invoke-virtual {v0, v4}, Ljava/util/Calendar;->get(I)I

    move-result v4

    invoke-virtual {v2, v3, v4}, Lorg/json/JSONObject;->put(Ljava/lang/String;I)Lorg/json/JSONObject;

    .line 44
    const-string v3, "ts"

    invoke-virtual {v0}, Ljava/util/Calendar;->getTimeInMillis()J

    move-result-wide v4

    invoke-virtual {v2, v3, v4, v5}, Lorg/json/JSONObject;->put(Ljava/lang/String;J)Lorg/json/JSONObject;

    .line 46
    const/4 v0, 0x0

    invoke-static {p2, v0}, Lcom/inmobi/commons/uid/UIDUtil;->getMap(Landroid/content/Context;Lcom/inmobi/commons/uid/UID;)Ljava/util/Map;

    move-result-object v0

    invoke-static {v0, v2}, Lcom/inmobi/commons/uid/UIDUtil;->bindToJSON(Ljava/util/Map;Lorg/json/JSONObject;)V
    :try_end_0
    .catch Lorg/json/JSONException; {:try_start_0 .. :try_end_0} :catch_0

    .line 52
    invoke-virtual {v2}, Lorg/json/JSONObject;->toString()Ljava/lang/String;

    move-result-object v0

    :goto_1
    return-object v0

    .line 47
    :catch_0
    move-exception v0

    .line 48
    const-string v0, "IMCOMMONS_3.7.0"

    const-string v2, "Unable to create payload for sending ThinICE params"

    invoke-static {v0, v2}, Lcom/inmobi/commons/internal/Log;->debug(Ljava/lang/String;Ljava/lang/String;)V

    move-object v0, v1

    .line 50
    goto :goto_1
.end method
